package com.Shoping.service.impl;

import com.Shoping.dao.CommodityDao;
import com.Shoping.dao.impl.CommodityDaoImpl;
import com.Shoping.entity.Color;
import com.Shoping.entity.Commodity;
import com.Shoping.service.CommodityService;

import java.sql.SQLException;
import java.util.List;

public class CommodityServiceImpl implements CommodityService {
    private CommodityDao commodityDao = new CommodityDaoImpl();
    @Override
    public List<Commodity> selectByCgId(Integer cgId) throws SQLException {
        return commodityDao.selectByCgId(cgId);
    }

    @Override
    public Commodity selectByCmId(Integer cmId) throws SQLException {
        return commodityDao.selectByCmId(cmId);
    }

    @Override
    public List<Color> selectColorByCmId(Integer cmId) throws SQLException {
        return commodityDao.selectColorByCmId(cmId);
    }

    @Override
    public long count() throws SQLException {
        return commodityDao.count();
    }

    @Override
    public List<Commodity> selectByPath(int pageSize, int currentPath) throws SQLException {
        return commodityDao.selectByPath(pageSize,currentPath);
    }

    @Override
    public void modifyCommodityByCmId(Integer cmId) throws SQLException {
        commodityDao.modifyCommodityByCmId(cmId);
    }

    @Override
    public void updateCommodity(Commodity commodity) throws SQLException {
        commodityDao.updateCommodity(commodity);
    }

    @Override
    public void addCommodity(Integer cgId, String cmName, Double cmPrice, String cmDetails, String cmImg) throws SQLException {
        commodityDao.addCommodity(cgId,cmName,cmPrice,cmDetails,cmImg);
    }

    @Override
    public Integer selectCmId() throws SQLException {
        return commodityDao.selectCmId();
    }
}
